﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wa="clr-namespace:WhileAwayWpf"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions" xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="WhileAwayWpf.ScreenSaverWindow"
    Loaded="Window_Loaded" ShowInTaskbar="False" ResizeMode="NoResize" WindowState="Maximized" WindowStartupLocation="CenterScreen" WindowStyle="None" Title="Main Window" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">

    <Window.Resources>
    	<wa:EventCountdownConverter x:Key="EventCountdownConverter"/>
    	<Storyboard x:Key="PhotoEffectStoryboard" Completed="PhotoEffectStoryboardCompleted" >
    		<DoubleAnimation Storyboard.TargetName="AnimatedImageScaleTranform" 
    			Storyboard.TargetProperty="ScaleX" Duration="0:0:2.5" From="0" To=".5" />
    		<DoubleAnimation Storyboard.TargetName="AnimatedImageScaleTranform" 
    			Storyboard.TargetProperty="ScaleY" Duration="0:0:2.5" From="0" To=".5" />
    		<DoubleAnimation
    			Storyboard.TargetProperty="Angle"
    			Duration="0:0:2.5" From="270" To="0" Storyboard.TargetName="AnimatedImageRotateTransform" />
			

    		<DoubleAnimation 
    			Storyboard.TargetName="AnimatedImageScaleTranform" 
    			Storyboard.TargetProperty="ScaleX" BeginTime="0:0:7.5" Duration="0:0:2.5" From=".5" To="0" />
    		<DoubleAnimation 
    			Storyboard.TargetName="AnimatedImageScaleTranform" 
    			Storyboard.TargetProperty="ScaleY" BeginTime="0:0:7.5" Duration="0:0:2.5" From=".5" To="0" />
    		<DoubleAnimation
    			Storyboard.TargetProperty="Angle"
    			BeginTime="0:0:7.5" Duration="0:0:2.5" From="0" To="270" Storyboard.TargetName="AnimatedImageRotateTransform" />
    		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Pin" Storyboard.TargetProperty="(UIElement.Visibility)">
    			<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>
    			<DiscreteObjectKeyFrame KeyTime="00:00:02.5000000" Value="{x:Static Visibility.Visible}"/>
    			<DiscreteObjectKeyFrame KeyTime="00:00:07.5000000" Value="{x:Static Visibility.Hidden}"/>
    		</ObjectAnimationUsingKeyFrames>
    	</Storyboard>
    </Window.Resources>

	<Grid x:Name="LayoutRoot">
		<Grid.Background>
			<ImageBrush ImageSource="images\941800_64041425.jpg"  />
		</Grid.Background>
		<VisualStateManager.CustomVisualStateManager>
			<ic:ExtendedVisualStateManager/>
		</VisualStateManager.CustomVisualStateManager>
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="MessageStates">
				<VisualStateGroup.Transitions>
					<VisualTransition GeneratedDuration="00:00:00.3000000"/>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="MessagesActive">
					<Storyboard>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="messageLogUserControl" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:02.4000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="MessagesInactive"/>
			</VisualStateGroup>
			<VisualStateGroup x:Name="ButtonStates">
				<VisualStateGroup.Transitions>
					<VisualTransition GeneratedDuration="00:00:00.3000000"/>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="ButtonActive">
					<Storyboard>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="buttonImBack" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="ButtonInactive">
					<Storyboard/>
				</VisualState>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
        
		<Border RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="10" BorderBrush="White">
			<Border.RenderTransform>
				<TransformGroup>
					<ScaleTransform x:Name="AnimatedImageScaleTranform" 
						ScaleX=".5" ScaleY=".5" />
					<RotateTransform x:Name="AnimatedImageRotateTransform"
						Angle="0" />
				</TransformGroup>
			</Border.RenderTransform>
			<Grid>
				<Image x:Name="MyImage"  />
				<Image x:Name="Pin" HorizontalAlignment="Center" VerticalAlignment="Top" Height="50" Source="images\RoundPin.png" />
	        </Grid>
		</Border>
        
		<Border x:Name="TopMessageBorder" Opacity=".8" BorderBrush="PapayaWhip" BorderThickness="5" CornerRadius="20" Padding="10" VerticalAlignment="Top" HorizontalAlignment="Center" d:LayoutOverrides="VerticalAlignment" RenderTransformOrigin="0.5,2">
			<Border.Background>
				<LinearGradientBrush >
					<GradientStop Color="Aqua" Offset="0"/>
					<GradientStop Color="LightBlue" Offset=".5"/>
				</LinearGradientBrush>
			</Border.Background>
			<Border.LayoutTransform>
				<TransformGroup>
					<ScaleTransform/>
					<SkewTransform/>
					<RotateTransform/>
					<TranslateTransform/>
				</TransformGroup>
			</Border.LayoutTransform>
			<Border.RenderTransform>
				<TransformGroup>
					<ScaleTransform/>
					<SkewTransform/>
					<RotateTransform/>
					<TranslateTransform/>
				</TransformGroup>
			</Border.RenderTransform>
			<StackPanel x:Name="TopMessagePanel">
				<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
					<TextBlock FontSize="28" VerticalAlignment="Top" Text="{Binding UserName}" HorizontalAlignment="Center" />
					<TextBlock FontSize="28" VerticalAlignment="Top" Text=" is away right now" HorizontalAlignment="Center" />
				</StackPanel>
				<TextBlock FontSize="28" Text="{Binding Message}" TextAlignment="Center" VerticalAlignment="Top" HorizontalAlignment="Center" />
				<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
					<TextBlock FontSize="20" VerticalAlignment="Top" Text="Expected return: " HorizontalAlignment="Center" />
					<TextBlock x:Name="ReturnCountdownText" Text="{Binding ReturnTimeRemaining, Converter={StaticResource EventCountdownConverter}, Mode=Default}" FontSize="20" VerticalAlignment="Top" HorizontalAlignment="Center" />
				</StackPanel>
			</StackPanel>
		</Border>

		<Border x:Name="MessageLogBorder" Panel.ZIndex="12" Margin="0" HorizontalAlignment="Left" d:LayoutOverrides="Height" VerticalAlignment="Center" >
			<wa:MessageLogUserControl x:Name="messageLogUserControl" Opacity="0.6" >
				<i:Interaction.Triggers>
					<i:EventTrigger EventName="MouseEnter">
						<ic:GoToStateAction StateName="MessagesActive"/>
					</i:EventTrigger>
					<i:EventTrigger EventName="MouseLeave">
						<ic:GoToStateAction StateName="MessagesInactive"/>
					</i:EventTrigger>
				</i:Interaction.Triggers>
			</wa:MessageLogUserControl>
		</Border>

		<Button Height="23" x:Name="buttonImBack" Width="75" Click="buttonImBack_Click" Opacity="0.5" Content="I'm back!" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom">
			<i:Interaction.Triggers>
				<i:EventTrigger EventName="MouseLeave">
					<ic:GoToStateAction StateName="ButtonInactive"/>
				</i:EventTrigger>
				<i:EventTrigger EventName="MouseEnter">
					<ic:GoToStateAction StateName="ButtonActive"/>
				</i:EventTrigger>
			</i:Interaction.Triggers>
		</Button>
	</Grid>
</Window>
